<?php include_once 'layout/heard.php'?>
<body style="background:#f5f5f5; padding-bottom:50px;">

<div class="content head_bg">
    <div class="head">
        <div class="nav_ico">
            <span class="ico01"></span>
            <span class="ico02"></span>
            <span class="ico03"></span>
        </div>
        <h1>待取货</h1>
        <a href="?md=riders&cl=riders&at=messageConten" class="news_ico"><span><?php echo $newCount; ?></span></a>
    </div>
</div>

<div class="nav_hs"></div>
<div class="nav_bg">
    <div class="nav_com">
        <dl>
            <dd><img src="webroot/riders/images/logo.png"></dd>
            <dt><?php echo $_SESSION['riders']['tel']?></dt>
        </dl>
        <ul>
            <li><a class="grxx" href="?md=riders&cl=riders&at=personageInfo">个人信息</a></li>
            <li><a class="lsdd" href="?md=riders&cl=riders&at=orderHistory">历史订单</a></li>
            <li><a class="wdqb" href="?md=riders&cl=riders&at=myWallet">我的钱包</a></li>
            <li><a class="cjwt" href="?md=riders&cl=riders&at=FQA">常见问题</a></li>
            <li><a class="xxzx" href="?md=riders&cl=riders&at=messageConten">消息中心</a></li>
        </ul>
    </div>
</div>

<div class="content order_list_bg">
    <div class="order_list">
        <ul>
            <?php
            if($rsp_list){
                foreach ($rsp_list as $v){
                    if($v['shop_delivery_address']){
                        $address = $v['shop_delivery_address'];
                    }else{
                        $address = $v['orderInfo']['receiver_address'];
                    }
                    echo '   	<li id="express_'.$v['id'].'">
                    <h3>
                        <p><s>'.$v['shop_pickup_time'].' 前取货</s></p>
                        <span>￥<b>'.($v['express_fee']+$v['tip']).'</b></span>                    
                    </h3>
                    <h4>
                        <b>取货点：'.$v['shopInfo']['storename'].'</b>
                        <span>'.$v['shopInfo']['address'].'</span>
                    </h4>
                    <h5>收货点：'.$address.'</h5>
                    <label>配送距离：<span>'.round($v['orderInfo']['distance']/1000,2).'</span> 公里</label>

                    <div class="box_bnt">
                        <a href="?md=riders&cl=riders&at=orderDetails_pick&express_id='.$v['id'].'">查看详情</a>
                        
                        <a class="bnt_qrqh" href="javascript:void(0)" code="'.$v['id'].'">确认取货</a>
                    </div>
                </li>';
                }
            }

            ?>
        </ul>
    </div>
</div>
<!--<a class="scanQRCode" href="javascript:void(0)"  code="'.$v['QRCode'].'">扫码取货</a>-->

<?php if($rsp_list){
    $display = 'style="display: none"';
}else{
    $display = '';
}
?>
<div class="content no_order" <?php echo $display?>>
    <dl>
        <dd><img src="webroot/riders/images/no_order.png"></dd>
        <dt>还没有待取货订单，快去抢单吧！</dt>
    </dl>
</div>

<div class="menu_bg">
    <div class="content">
        <a class="a_xrw" href="?md=riders&cl=riders&at=OrdersList">
            <span></span>
            <p>新任务</p>
        </a>
<!--        hov  new -->
        <a class="a_dqh hov" href="?md=riders&cl=riders&at=assignPick">
            <span></span>
            <p>待取货</p>
        </a>
        <a class="a_psz " href="?md=riders&cl=riders&at=dispatching">
            <span></span>
            <p>配送中</p>
        </a>
        <a class="a_ywc" href="?md=riders&cl=riders&at=finishOrderList">
            <span></span>
            <p>已完成</p>
        </a>
    </div>
</div>

<a class="bnt_refresh" href="javascript:location.reload();">刷新</a>

<div class="group_tc_bg" id="qrqh_pop">
    <div class="group_tc">
        <h3>温馨提示！</h3>
        <p>请到门店拿到商品确认无误后，再按确认取货，虚假按确认取货将会被平台惩罚哦！</p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">还未到店</a>
            <a href="javascript:void(0)" class="btn2">确认取货</a>
        </div>
    </div>
</div>


<div class="group_tc_bg" id="zhty_pop">
    <div class="group_tc">
        <h3>很遗憾！</h3>
        <p>您的骑手资格已被门店停用，请联系门店人员，开启后才可恢复接单。</p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">暂不联系</a>
            <a href="javascript:void(0)" class="btn2">立即联系</a>
        </div>
    </div>
</div>

<div class="group_tc_bg" id="ridersT">
    <div class="group_tc">
        <h3>很遗憾！</h3>
        <p id="con"></p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">取消</a>
            <a href="?md=riders&cl=riders&at=riders_approve" class="btn2">再次认证</a>
        </div>
    </div>
</div>

<div class="group_tc_bg" id="ridersD">
    <div class="group_tc">
        <h3>很遗憾！</h3>
        <p>您当前尚未提交审核资料，请提交认证资料。</p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">取消</a>
            <a href="?md=riders&cl=riders&at=riders_approve" class="btn2">去认证</a>
        </div>
    </div>
</div>


<div class="group_tc_bg" id="ridersB">
    <div class="group_tc">
        <h3>很遗憾！</h3>
        <p>您提交审核资料不符合要求。</p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">取消</a>
            <a href="javascript:void(0)" class="btn2">确定</a>
        </div>
    </div>
</div>


<div class="group_tc_bg" id="ridersC">
    <div class="group_tc">
        <!--        <h3>很遗憾！</h3>-->
        <p>资料已提交 请耐心等待审核结果。</p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">取消</a>
            <a href="javascript:void(0)" class="btn2">确定</a>
        </div>
    </div>
</div>

<div class="group_tc_bg" id="QRCode">
    <div class="group_tc">
        <p></p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">取消</a>
            <a href="javascript:void(0)" class="btn2">确定取货</a>
        </div>
    </div>
</div>
<!--autoplay="autoplay"-->
<audio id="myaudio" style="display: none" src="webroot/riders/tips.mp3"  controls="controls" preload="preload" >
    不支持audio
</audio>


<?php
$Config = Config::getInstance();
$getWechat = $Config->getWechat();
$jssdk = new JSSDK($getWechat['appid'], $getWechat['appsecret']); //元祖公众号
$signPackage = $jssdk->GetSignPackage();
$baseHost = "http://" . $_SERVER['HTTP_HOST'];
?>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
    //wx.config({
    //    debug: false,
    //    appId: '<?php //echo $signPackage["appId"]; ?>//',
    //    timestamp: <?php //echo $signPackage["timestamp"]; ?>//,
    //    nonceStr: '<?php //echo $signPackage["nonceStr"]; ?>//',
    //    signature: '<?php //echo $signPackage["signature"]; ?>//',
    //    jsApiList: [
    //        'checkJsApi',
    //        'scanQRCode'
    //    ]
    //});
    // wx.error(function(res) {
    //     alert("出错了：" + res.errMsg);
    // });

    // wx.ready(function() {
    //     // document.getElementById("myaudio").play();
    //     wx.checkJsApi({
    //         jsApiList : ['scanQRCode'],
    //         success : function(res) {
    //
    //         }
    //     });
    //     //点击按钮扫描二维码
    //     $(".scanQRCode").click(function(){
    //         var code = $(this).attr('code');
    //         var express_id = $(this).next().attr('code');
    //         wx.scanQRCode({
    //             needResult : 1,
    //             scanType : ["qrCode"],
    //             success : function(res) {
    //                 var result = res.resultStr;
    //                 if(result !== code){
    //                     popup("取货码错误")
    //                 }else{
    //                     $.ajax({
    //                         url:"?md=riders&cl=riders&at=assPick",
    //                         type:"post",
    //                         dataType:"json",
    //                         data:{'express_id':express_id},
    //                         success:function (d) {
    //                             if(d.status == 1){
    //                                 $("#express_"+express_id).remove();
    //                                 popup("取货成功");
    //                             }else{
    //                                 popup(d.msg);
    //                             }
    //                         }
    //                     });
    //                 }
    //                 // window.location.href = result;
    //             },
    //         });
    //     })
    // });
</script>
<script>
    $(function () {
        $.ajax({
            url:"?md=riders&cl=riders&at=ridersT",
            type:"post",
            dataType:"json",
            data:{'tel':13888888888},
            success:function (d) {
                console.log(d)
                if( d.status == 1 && d.initiate == 2){  // 审核通过 但被停用
                    $("#zhty_pop").fadeIn();
                }
                if (d.status == 4) {                    // 审核通过 禁止接单
                    $("#zhty_pop").fadeIn();
                }

                if (d.status == 10) {  // 没有提交审核资料 / 刚注册 = 10
                    $("#ridersD").fadeIn();
                }
                if(d.status == 0){      // 0 = 已经提交未审核
                    $("#ridersC").fadeIn();
                }

                if (d.status == 3){                     // 审核未通过
                    $("#con").html("骑手认证资料审核未通过，请查看未通过理由后，可重新填写再次提交认证。<br>未通过理由："+d.msg);
                    $("#ridersT").fadeIn();
                    $("#riderReg").show();
                }

                if (d.status == 2){                     // 审核未通过 不得申请
                    $("#ridersB").fadeIn();
                }

            }
        })
    })



    // ------------------------------------------------ 是否有被取消订单 --------------------------------------- //
    $.ajax({
        url:"?md=riders&cl=riders&at=getCanCelOrders",
        type:"post",
        dataType:"json",
        success:function (d) {
            if(d && d.status == 1){
                popup(d.msg);
                // $(d.result).each(function (k,v) {
                // 	$("#Cancel").find('p').html("取货点："+v.address+'<br/>收货点：'+v.receiver_address);
                // 	$("#Cancel").fadeIn();
                // });
            }
        }
    })
</script>



<?php include_once 'layout/rfooter.php'?>
